home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / Label.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-01-30  |  3.1 KB  |  85 lines

  1. package symantec.itools.db.awt;
  2.  
  3. import java.io.IOException;
  4. import symantec.itools.db.pro.ProjBinder;
  5. import symantec.itools.db.pro.ProjLink;
  6. import symantec.itools.db.pro.RelationView;
  7. import symjava.sql.SQLException;
  8.  
  9. public class Label extends java.awt.Label implements ProjLink {
  10.    private ProjBinder m_ProjBinder;
  11.    private String m_labelText;
  12.    private int m_treatBlankAs;
  13.    private boolean m_DynamicUpdate = false;
  14.  
  15.    public Label() {
  16.       super("<dbAWARE Label>");
  17.    }
  18.  
  19.    public Label(String s) {
  20.       this.m_labelText = s;
  21.    }
  22.  
  23.    public void setBinding(RelationView relView, String projection) {
  24.       try {
  25.          int projectionNumber = relView.findProjByName(projection);
  26.          relView.bindProj(projectionNumber, this);
  27.       } catch (SQLException Ex) {
  28.          this.raiseException("SQLException from Label.setBinding: " + ((Throwable)Ex).getMessage());
  29.       }
  30.    }
  31.  
  32.    public void init(ProjBinder binder) {
  33.       this.m_ProjBinder = binder;
  34.    }
  35.  
  36.    public void notifyDataChange(ProjBinder binder) {
  37.       if (binder != null) {
  38.          this.m_ProjBinder = binder;
  39.       }
  40.  
  41.       String data = new String();
  42.  
  43.       try {
  44.          if (binder.isReadable() && !binder.isNull()) {
  45.             data = binder.getStringValue();
  46.          }
  47.       } catch (SQLException Ex) {
  48.          this.raiseException("SQLException from Label.notifyDataChange: " + ((Throwable)Ex).getMessage());
  49.       } catch (IOException Ex) {
  50.          this.raiseException("IOException from Label.notifyDataChange: " + ((Throwable)Ex).getMessage());
  51.       }
  52.  
  53.       if (data.equals("")) {
  54.          data = this.m_labelText;
  55.       }
  56.  
  57.       ((java.awt.Label)this).setText(data);
  58.    }
  59.  
  60.    public boolean notifySetData(ProjBinder binder) throws SQLException {
  61.       return true;
  62.    }
  63.  
  64.    public void setTreatBlankAs(String blank) {
  65.       if ((new String(blank)).toUpperCase().equals("DEFAULT")) {
  66.          this.m_treatBlankAs = 0;
  67.       } else if ((new String(blank)).toUpperCase().equals("NULL")) {
  68.          this.m_treatBlankAs = 1;
  69.       } else {
  70.          if ((new String(blank)).toUpperCase().equals("EMPTY")) {
  71.             this.m_treatBlankAs = 2;
  72.          }
  73.  
  74.       }
  75.    }
  76.  
  77.    void raiseException(String text) {
  78.       System.out.println(text);
  79.    }
  80.  
  81.    public void setDynamicUpdate(boolean update) {
  82.       this.m_DynamicUpdate = update;
  83.    }
  84. }
  85.